package com.ts.api.meta.task;

import com.ts.api.common.util.RedisCache;
import com.ts.api.meta.AbstractMetaReport;
import com.ts.api.meta.MetaReportFactory;
import com.ts.api.module.api.convert.plan.context.ApiPlanConvertContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 *  元数据上报-计划上线状态
 *
 *  @author Pan
 */
@Component
public class MetaPlanOnlineReportTask extends AbstractMetaReport {

    @Autowired
    private MetaReportFactory metaReportFactory;
    @Autowired
    private ApiPlanConvertContext apiPlanConvertContext;
    @Autowired
    private RedisCache redisCache;

    @Override
    public void report() {
        metaReportFactory.report("plan_status", () -> {
            //  获取已对接的所有主体主键id
            List<String> keys = apiPlanConvertContext.listConvertKey();
            redisCache.setCacheList("api_plan_docking:all", keys);
        });
    }
}
